package com.lion.common.modules.uaa.web.models.params;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @author Chris Chan
 * Create On 2025/8/8 下午12:30
 * Use for:
 * Explain:
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "令牌参数")
public class TokenParam implements Serializable {
    private static final long serialVersionUID = 1L;
    @NotBlank(message = "令牌不能为空")
    // 令牌格式，以Bearer开头，空格后跟着令牌字符串
    @Pattern(regexp = "^Bearer\\s+[a-zA-Z0-9-._~+/=]+$", message = "令牌格式错误,请输入正确的令牌")
    @Schema(description = "令牌")
    private String token;

    public static TokenParam of(String token) {
        return new TokenParam(token);
    }

    public static TokenParam create(String token) {
        return new TokenParam(token);
    }
}
